package com.yupi.cloudpicturebackend.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

/*
 * 用户角色枚举
 * */
@Getter
public enum UserRoleEnum {
    User("用户", "user"),
    Admin("管理员", "admin");

    private final String text;

    private final String value;

    UserRoleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /*
     *根据value获取枚举值
     * */
    public static UserRoleEnum getEnumByValue(String value) {
        if (ObjUtil.isEmpty(value)) {
            return null;
        }
        for (UserRoleEnum userRoleEnums : UserRoleEnum.values()) {
            if (userRoleEnums.getValue().equals(value)) {
                return userRoleEnums;
            }
        }
        return null;
    }
}
